package com.gxc.controller;

import com.gxc.config.PropertiesConfigBean;
import com.gxc.entity.User;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * PropertiesController.
 *
 * @author 宫新程
 * @since 2018/12/18 3:37 PM
 */
@Controller
public class PropertiesController {

  @Resource private PropertiesConfigBean propertiesConfigBean;

  @RequestMapping("/properties")
  @ResponseBody
  public String properties() {
    return propertiesConfigBean.getName() + "：" + propertiesConfigBean.getAge();
  }

  /** 返回properties中的信息到页面 thymeleaf. */
  @RequestMapping("/prop/user")
  public String user(Model model) {
    User user = new User();
    user.setName(propertiesConfigBean.getName());
    user.setAge(Integer.parseInt(propertiesConfigBean.getAge()));
    model.addAttribute("user", user);
    return "test1";
  }

  @RequestMapping("/char")
  @ResponseBody
  public String getPathValue(String str) {
    System.out.println(str);
    return str;
  }
}
